home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / shadow-3.1.4 / mkrmdir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-26  |  1.3 KB  |  78 lines

  1. /*
  2.  * Copyright 1991, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #include <fcntl.h>
  13. #include "config.h"
  14.  
  15. #ifndef lint
  16. static    char    sccsid[] = "@(#)mkrmdir.c    3.3    07:43:57    9/17/91";
  17. #endif
  18.  
  19. #ifdef    NEED_MKDIR
  20. /*
  21.  * mkdir - create a directory
  22.  *
  23.  *    mkdir is provided for systems which do not include the mkdir()
  24.  *    system call.
  25.  */
  26.  
  27. int
  28. mkdir (dir, mode)
  29. char    *dir;
  30. int    mode;
  31. {
  32.     int    status;
  33.  
  34.     if (fork ()) {
  35.         while (wait (&status) != -1)
  36.             ;
  37.  
  38.         return status >> 8;
  39.     }
  40. #ifdef    USE_SYSLOG
  41.     closelog ();
  42. #endif
  43.     close (2);
  44.     open ("/dev/null", O_WRONLY);
  45.     umask (0777 & ~ mode);
  46.     execl ("/bin/mkdir", "mkdir", dir, 0);
  47.     _exit (128);
  48.     /*NOTREACHED*/
  49. }
  50. #endif
  51. #ifdef    NEED_RMDIR
  52. /*
  53.  * rmdir - remove a directory
  54.  *
  55.  *    rmdir is provided for systems which do not include the rmdir()
  56.  *    system call.
  57.  */
  58.  
  59. int
  60. rmdir (dir)
  61. char    *dir;
  62. {
  63.     int    status;
  64.  
  65.     if (fork ()) {
  66.         while (wait (&status) != -1)
  67.             ;
  68.  
  69.         return status >> 8;
  70.     }
  71.     close (2);
  72.     open ("/dev/null", O_WRONLY);
  73.     execl ("/bin/rmdir", "rmdir", dir, 0);
  74.     _exit (128);
  75.     /*NOTREACHED*/
  76. }
  77. #endif
  78.